home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / DrawShapes / UBetterFeedbackCmd.p < prev    next >
Encoding:
Text File  |  1990-10-25  |  3.4 KB  |  99 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n+]}
  2. { UBetterFeedbackCmd.p }
  3. { Copyright © 1988-1990 by Apple Computer, Inc. All rights reserved.}
  4.  
  5. {[f-]}
  6. {    This unit attempts to provide smooth flicker-free feedback during command tracking.
  7.  
  8.           T H E O R Y   O F   O P E R A T I O N
  9.  
  10.     By synchronizing drawing to the vertical retrace interrupt, this unit attempts
  11.     to improve the feedback that mouse trackers provide.
  12.     
  13.     Ideally, this behavior would be part of MacApp's TApplication.TrackMouse method.
  14.     What TApplication.TrackMouse should really do is:
  15.         a) wait for the vertical retrace interrupt of the device that the view most intersects
  16.         b) erase the old tracker feedback by calling tracker.TrackFeedback(…, turn It Off, …)
  17.         c) immediately draw the new feedback by calling tracker.TrackFeedback(…, turn It on, …)
  18.  
  19.     However, with the current architecture, this is impossible. TApplication.TrackMouse currently
  20.     does the following:
  21.         a) call tracker.TrackFeedback(…, turn It Off, …) to erase the previous tracker feedback
  22.         b) call tracker.TrackMouse(trackMove, …) to tell the tracker the track phase
  23.         c) call tracker.TrackFeedback(…, turn It On, …) to draw the new tracker feedback
  24.  
  25.     UBetterFeedbackCmd provides a way to work within the current architecture to provide a close
  26.     attempt at smooth flicker-free feedback. To take advantage of this unit, create a
  27.     subclass of TBetterFeedbackCmd. Then, OVERRIDE PROCEDURE TBetterFeedbackCmd.TrackFeedback()
  28.     and as the first statement of this method call:
  29.             INHERITED TrackFeedback(anchorPoint, nextPoint, turnItOn, mouseDidMove);
  30.     so that TBetterFeedbackCmd.TrackFeedback can synch to the vertical retrace interrupt.
  31.     Then the tracker should go ahead and draw/erase the feedback.
  32.     
  33.     For an example, see DrawShapes: TShapeSketcher, TShapeDragger, and TShapeSelector.
  34.     
  35. }
  36. {[f+]}
  37.  
  38. UNIT UBetterFeedbackCmd;
  39.  
  40.     INTERFACE
  41.  
  42.         USES
  43.             { • MacApp }
  44.             UMacApp,
  45.  
  46.             { • Building Blocks }
  47.  
  48.             { • Required for this unit's interface }
  49.  
  50.             { • Implementation Use }
  51.              Start, Retrace;
  52.  
  53.         CONST
  54.  
  55.             kInstall            = TRUE;                            { pass to BetterFeedback:
  56.                                                                  install our VBL? }
  57.             kBetterFeedbackDesired = TRUE;                        { pass to IBetterFeedbackCmd:
  58.                                                                  desire better feedback? }
  59.  
  60.         TYPE
  61.             TBetterFeedbackCmd     = OBJECT (TCommand)
  62.  
  63.                 fBetterFeedbackInstalled: BOOLEAN;            { are the synchronization routines in? }
  64.  
  65.                 fBetterFeedbackDesired: BOOLEAN;            { want the synchronization routines? }
  66.                                                                                 
  67.                 PROCEDURE TBetterFeedbackCmd.IBetterFeedbackCmd(itsCmdNumber: CmdNumber;
  68.                                                           itsDocument: TDocument; itsView: TView;
  69.                                                           itsScroller: TScroller;
  70.                                                           betterFeedbackDesired: BOOLEAN);
  71.  
  72.                 PROCEDURE TBetterFeedbackCmd.Free; OVERRIDE;
  73.  
  74.                         { for tracking }
  75.                 PROCEDURE TBetterFeedbackCmd.BetterFeedback(install: BOOLEAN);
  76.  
  77.                 PROCEDURE TBetterFeedbackCmd.WaitBetterFeedback;
  78.  
  79.                 FUNCTION  TBetterFeedbackCmd.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
  80.                                                      previousPoint, nextPoint: VPoint;
  81.                                                      mouseDidMove: Boolean): TCommand; OVERRIDE;
  82.                 
  83.                 PROCEDURE TBetterFeedbackCmd.TrackFeedback(anchorPoint, nextPoint: VPoint; turnItOn,
  84.                                                         mouseDidMove: Boolean); OVERRIDE;
  85.  
  86.                         { Inspecting }
  87.  
  88.                 PROCEDURE TBetterFeedbackCmd.Fields(PROCEDURE
  89.                                                DoToField(fieldName: Str255; fieldAddr: Ptr;
  90.                                                          fieldType: INTEGER)); OVERRIDE;
  91.  
  92.                 END;
  93.  
  94.     IMPLEMENTATION
  95.  
  96.         {$I UBetterFeedbackCmd.inc1.p}
  97.  
  98. END.
  99.